package configs

import (
	"log"
	"os"

	"github.com/timest/env"
)

var (
	// EnvConfig :
	EnvConfig *config = new(config)
	HOST      string
)

type config struct {
	ProjectEnv      string `env:"PROJECT_ENV" default:"dev"`
	APIVersion      string `env:"API_VERSION" default:"Commit ID"`
	ServiceHttpPort string `env:"SERVICE_HTTP_PORT" default:"80"`
}

func InitConfig() {
	EnvConfig = new(config)
	env.IgnorePrefix()
	err := env.Fill(EnvConfig)
	log.Printf("[INFO] config :%+v\n", EnvConfig)
	if err != nil {
		panic(err)
	}
	HOST, _ = os.Hostname()
	InitCron()
}
